//
//  GroupRouter.swift
//  eemall
//
//  Created by zhuxietong on 2019/1/4.
//  Copyright © 2019 tianrun. All rights reserved.
//

import Foundation
import soapp
// import mosdks

public enum GroupLink:String,AppRouter {
    case join = "groupjoin" //活动
    case unkown = ""
    case http = "http"
    
    case group = "groups"
    case groupGoods = "groupGoods"
    case groupOrder = "groupsorder"
    
    @discardableResult
    public static func open(link: String, at: UIViewController?, present: NavPresentType?=nil) -> Bool {
        print("-GroupLinks--s0s00",link)
        let info = AppLink.paw(link: link)

        if let ilink = GroupLink(rawValue: info.path)
        {

            var newCtr:UIViewController? = nil
            var canopen = false
            switch ilink{
            case .join,.group:
                let ctr = GroupInfoCtr()
                ctr.mo.model = info.params.mutable_dictionary
                newCtr = ctr
            case .groupOrder:
                let ctr = GroupOrderDetailCtr()
                ctr.mo.model = info.params.mutable_dictionary
//                print("+++_S----|\(info)")
                newCtr = ctr
            case .groupGoods:
                GroupActive.seeDetail(obj: info.params.mutable_dictionary, at: at)
            default:
                break
            }
            canopen = AppLink.show(at: at, controller: newCtr, present: NavPresentType.defaultPush)
            return canopen
        }
        
        return false
    }
    
    var msg:EeMsgType{
        get{
            return EeMsgType(rawValue: self.rawValue)
        }
    }
    
    public static var orderMsg:EeMsgType{
        get{
            return EeMsgType(rawValue: GroupLink.groupOrder.rawValue)
        }
    }
    
}




